package com.codeczx.slidingconflictdemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OutsideConflictActivity extends AppCompatActivity {
    private static final String TAG = "OutsideConflictActivity";
    @BindView(R.id.view_pager)
    MyViewPager viewPager;

    private String[] viewContents = {"View1","View2","View3","View4"};
    private List<View> mViews;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_outside_conflict);
        ButterKnife.bind(this);
        mViews = new ArrayList<>();
        initData(true);
    }

    private void initData(boolean isListView){
        if(isListView){
            List<String> datas = new ArrayList<>();
            for(int i = 0;i<50;i++){
                datas.add("item"+i);
            }
            for(int i = 0;i<viewContents.length;i++){
                ListView listView = new ListView(this);
                ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,datas);
                listView.setAdapter(adapter);
                mViews.add(listView);
            }
        }else{
            for(int i = 0;i<viewContents.length;i++){
                TextView textView = new TextView(this);
                textView.setGravity(Gravity.CENTER);
                textView.setText(viewContents[i]);
                textView.setClickable(true);
                mViews.add(textView);
            }
        }
        Log.i(TAG, "initData: mViews size:"+mViews.size());
        viewPager.setAdapter(new MyPagerAdapter(mViews));
    }
}
